-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API with queue history in CSV #166
base: master
Are you sure you want to change the base?
Conversation
@@ -86,4 +89,13 @@ | |||
@PathVariable("queueId") String queueId) { | |||
return ResponseEntity.ok(queueService.getQueueEvents(queueId)); | |||
} | |||
|
|||
@GetMapping(path = "/queue/{queueId}/history", produces = "text/csv") | |||
@ResponseBody |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need @ResponseBody
?
|
||
@GetMapping(path = "/queue/{queueId}/history", produces = "text/csv") | ||
@ResponseBody | ||
public QueueEventsCsvResponse getQueueHistoryCSV( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename function to getQueueEventsCsv
and make the path "/queue/{queueId}/eventsCsv"
import java.nio.charset.StandardCharsets; | ||
|
||
@Component | ||
public class QueueEventsCsvResponseConverter extends AbstractHttpMessageConverter<QueueEventsCsvResponse> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's write a converter for QueueEventsResponse
and remove QueueEventsCsvResponse
and getQueueEventsInCsv
service function.
As per this, it will use the media type to determine the converter, this should work. Can you try?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to use Accept
header to decide on the response content, then maybe just one endpoint would be enough?
GET /queue/{queueId}/events
withAccept: application/json
would return the events in JSON,GET /queue/{queueId}/events
withAccept: text/csv
would return a CSV
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QueueEventsResponse
does not include queue name. I wanted to use it to make the filename more accessible. Do you think a generic name like history.csv
is ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the Accept header if that works would be the best way, in my opinion.
I wanted to use it to make the filename more accessible.
Yeah, that would be desirable. Can you try adding the queue Id and name to QueueEventsResponse
? In case that's difficult, we can fallback to a generic name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, and happy hacking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@piotrwasko Can you fix the tests? Looks like you are missing some imports
Is this pr right ? |
PR resolves #165